package com.edu.controller;

import com.edu.dao.impl.MyBatisNewsDaoImpl;
import com.edu.data.News;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/news")
public class EasyBuyNewsController {
    MyBatisNewsDaoImpl dao = new MyBatisNewsDaoImpl();

    @RequestMapping("/main")
    public String mainNews(Model model, HttpServletRequest req){
        List<News> newsList = dao.getAllNews();
        model.addAttribute("allNews",newsList);
        return "index";
    }
}
